#!/bin/sh

CURRDIR=`pwd`
KERNEL_DIR=$CURRDIR/linux-stable
#
# kernel version branch, at present it could be:
#   kernel-4.14 : the linux-4.14.y version branch
#   centos-3.10 : the centos kernel 3.10.0-862.el7
#   centos-4.18 : the centos kernel 4.18.0-80.7.2.el7
#
KERNEL_BRANCH=centos-4.18

QEMU_DIR=$CURRDIR/qemu/qemu-2.12.1
QEMU_BRANCH=master

ROOTFS_DIR=$CURRDIR/rootfs/busybox
ROOTFS_BRANCH=github

# sync current git
git pull

if [ -d $KERNEL_DIR ]
then
cd $KERNEL_DIR
echo Entering into `pwd`
git pull
cd $CURRDIR
else
git clone https://github.com/wxx213/kernel-stable.git -b $KERNEL_BRANCH $KERNEL_DIR
fi

if [ -d $QEMU_DIR ]
then
cd $QEMU_DIR
echo Entering into `pwd`
git pull
cd $CURRDIR
else
git clone https://github.com/wxx213/qemu-2.12.git -b $QEMU_BRANCH $QEMU_DIR
fi

if [ -d $ROOTFS_DIR ]
then
cd $ROOTFS_DIR
echo Entering into `pwd`
git pull
cd $CURRDIR
else
git clone https://github.com/wxx213/busybox_rootfs.git -b $ROOTFS_BRANCH $ROOTFS_DIR
fi
